// custom-tab-bar/index.js
import { storeBindingsBehavior } from 'mobx-miniprogram-bindings'
import { store } from '../store/store'
Component({
  options: {
    styleIsolation: 'shared'
  },
  behaviors: [storeBindingsBehavior],
  storeBindings: {
    store, // 指定要绑定的store,map数据
    fields: { // 指定要绑定的数据字段或计算属性
      active: 'activeIndex'
    },
    actions: { // 指定要绑定的方法
      updateActiveIndex: 'updateActiveIndex'
    }
  },
  data: {
    // active: 2,
    icon: {
      normal: 'https://img.yzcdn.cn/vant/user-inactive.png',
      active: 'https://img.yzcdn.cn/vant/user-active.png',
    },
    "list": [
      {
        "pagePath": "/pages/home/home",
        "text": "首页",
        "iconPath": "/images/tabs/home.png",
        "selectedIconPath": "/images/tabs/home-active.png"
      },
      {
        "pagePath": "/pages/message/message",
        "text": "消息",
        "iconPath": "/images/tabs/message.png",
        "selectedIconPath": "/images/tabs/message-active.png",
        "info": 5
      },
      {
        "pagePath": "/pages/contact/contact",
        "text": "联系我们",
        "iconPath": "/images/tabs/contact.png",
        "selectedIconPath": "/images/tabs/contact-active.png"
      }
    ]
  },
  methods: {
    onChange(e) {
      console.log(e);
      // this.setData({ active: e.detail });
      this.updateActiveIndex(e.detail)
      wx.switchTab({
        url: this.data.list[e.detail].pagePath
      })
    },
  },
  properties: {

  },

})

